package com.example.runningdemo.designModel.strategy;

/**
 * @program: Running-Demo
 * @description: 策略上下文
 * @author: kangwei
 * @create: 2024-08-12 09:51
 **/
public class StrategyContext {

    Payment payment;

    public StrategyContext(Payment payment) {
        this.payment = payment;
    }

    /**
     * 调用支付
     */
    public void getPayment() {
        payment.pay();
    }

    public static void main(String[] args) {
        new StrategyContext(new PaymentA()).getPayment();
        new StrategyContext(new PaymentB()).getPayment();
        new StrategyContext(new PaymentC()).getPayment();
    }
}
